<!--#include file="..\CheckSession.inc"-->
<!--#include file=..\getFormName.inc-->
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>In Lich</title>
</head>
<%
bNgay=SaveDate(request("bNgay"))
bNgay=cdate(bNgay)
bThu=weekday(bNgay)
if bThu=1 then
	bDate=cdate(bngay)-6
else
	bDate=cDate(bNgay)-(bThu-2)
end if
bdatec=cdate(bDate)+6
bngayht=Ngay(FormatDate(bNgay))
bthanght=Thang(FormatDate(bNgay))
bnamht=Nam(FormatDate(bNgay))
tungay=FormatDate(bDate)
denngay=FormatDate(bDatec)
sSQL="select * from lichcongtac where ngaythang >= '"& bDate &"' and ngaythang <= '"& bdatec &"' order by ngaythang,thoigian"
CAll RP("rptInLich.rpt",sSQL)
%>
<!-- #include file="SmartViewerActiveX.asp" -->
<%
	Conn.Close
	Set Conn=nothing
%>
<script language=vbscript runat=server>
	Function FormatDate(vDate)
	   If Not IsNull(vDate) Then
	        vM = Right("0" & Month(vDate), 2)
	        vD = Right("0" & Day(vDate), 2)
	        vY = Right("19" & Year(vDate), 4)
	        FormatDate = vD & "/" & vM & "/" & vY
	   End If
	End Function
	Function SaveDate(vDate)
		dim bvitri1
		dim bvitri2
	   vDate=trim(cstr(vDate))
	   bvitri1=instr(1,vDate,"/")
	   bMonth=left(vDate,bvitri1-1)
	   bvitri2=instr(bvitri1+1,vDate,"/")
	   Dim Temp
	   Temp=right(vDate,len(vDate)-bvitri1)
	   bDay=left(Temp,bvitri2-bvitri1-1)
	   bYear=right(vDate,len(vDate)-bvitri2)
       SaveDate=bDay+"/"+bMonth+"/"+bYear
	End Function
function RP(inReportName,inSQL)
	ReportName = Session("APPL_PHYSICAL_PATH") & "\report\" &inReportName
	
	If Not IsObject ( session("oApp") ) Then
	    Set session ("oApp") = Server.CreateObject("CrystalRuntime.Application")
	End If

	If IsObject(session("oRpt")) then
		Set session("oRpt") = nothing
	End if	

	Set session("oRpt") = session("oApp").OpenReport(ReportName,1)
	session("oRpt").MorePrintEngineErrorMessages = False
	session("oRpt").EnableParameterPrompting = False
	session("oRpt").DiscardSavedData
	
	Session("oRpt").Database.Tables(1).ConnectionProperties("Data Source") = Application("DataSource")
	Session("oRpt").Database.Tables(1).ConnectionProperties("Initial Catalog") =Application("DataBaseName")	
	Session("oRpt").Database.Tables(1).ConnectionProperties("User ID") = Application("DBUser")
	Session("oRpt").Database.Tables(1).ConnectionProperties("Password") = Application("DBPass")
	
	session("oRpt").ParameterFields(1).SetCurrentValue cstr(bngayht)
	session("oRpt").ParameterFields(2).SetCurrentValue cstr(bthanght)
	session("oRpt").ParameterFields(3).SetCurrentValue cstr(bnamht)
	session("oRpt").ParameterFields(4).SetCurrentValue cstr(tungay)
	session("oRpt").ParameterFields(5).SetCurrentValue cstr(denngay)

	session("oRpt").SQLQueryString = CStr(inSQL)	
	If Err.Number <> 0 Then
	    Response.Write "Error " & Err.number & " " & Err.description 
	Else
	    If IsObject(session("oPageEngine")) Then
     	   set session("oPageEngine") = nothing
	    End If
	    set session("oPageEngine") = session("oRpt").PageEngine
	End If
end function
Function Ngay(strngay)
	Ngay=mid(strngay,1,2)
End Function
Function Thang(strngay)
	Thang=mid(strngay,4,2)
End Function
Function Nam(strngay)
	Nam=mid(strngay,7,4)
End Function
</SCRIPT>